package com.chinasoft.mall.model;

import java.io.Serializable;
import java.util.HashMap;

import android.app.Activity;
import android.view.View;

import com.chinasoft.mall.framework.Config;

public class ActivityRecorder implements Serializable{
	private static final long serialVersionUID = 3079479420866756824L;
	private String activityName;
	private Class<? extends Activity> currentActivityclazz;
	private ActivityRecorder preActivity;
	private HashMap<String,Serializable> szs=new HashMap<String, Serializable>();
	private int activityType;
	private String imageurl;
	
	public String getImageurl() {
		return imageurl;
	}

	public void setImageurl(String imageurl) {
		this.imageurl = imageurl;
	}

	public int getActivityType() {
		return activityType;
	}
	
	public HashMap<String, Serializable> getSzs() {
		return szs;
	}

	public void setSzs(HashMap<String, Serializable> szs) {
		this.szs = szs;
	}

	public void setActivityType(int activityType) {
		this.activityType = activityType;
	}
	public ActivityRecorder getPreActivity() {
		return preActivity;
	}
	public void setPreActivity(ActivityRecorder preActivity) {
		this.preActivity = preActivity;
	}
	public Serializable getSz() {
		return szs.get(Config.INTENT_OBJ);
	}
	public Serializable getSz(String key) {
		return szs.get(key);
	}
	public void addSz(String key,Serializable value) {
		szs.put(key, value);
	}
	public String getActivityName() {
		return activityName;
	}
	public Class<? extends Activity> getCurrentActivityclazz() {
		return currentActivityclazz;
	}
	public ActivityRecorder(String activityName,
			Class<? extends Activity> currentActivityclazz,
			ActivityRecorder preActivity,Serializable sz) {
		super();
		this.activityName = activityName;
		this.currentActivityclazz = currentActivityclazz;
		this.preActivity = preActivity;
		szs.put(Config.INTENT_OBJ, sz);
	}
	public ActivityRecorder(Class<? extends Activity> currentActivityclazz,
			ActivityRecorder preActivity,Serializable sz) {
		super();
		this.activityName = currentActivityclazz.getSimpleName();
		this.currentActivityclazz = currentActivityclazz;
		this.preActivity = preActivity;
		szs.put(Config.INTENT_OBJ, sz);
	}
	
	/**
	 * 
	 * @return true 返回到最上层  false 继续返回
	 */
	public boolean backActivityRecorder(){
		if(preActivity==null){
			return true;
		}
		this.currentActivityclazz = preActivity.getCurrentActivityclazz();
		this.activityName = currentActivityclazz.getSimpleName();
		this.szs=preActivity.getSzs();
		this.activityType=preActivity.getActivityType();
		this.preActivity = preActivity.getPreActivity();
		return false;
	}
	@Override
	public String toString() {
		return "ActivityRecorder [activityName=" + activityName
				+ ", currentActivityclazz=" + currentActivityclazz
				+ ", preActivity=" + preActivity + ", sz=" + szs
				+ ", activityType=" + activityType + "]";
	}
}
